package com.example.service.impl;

import com.example.entity.vo.MenuVo;
import com.example.service.MenuService;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @Author: zhuxiaokang
 * @CreateTime: 2025-04-30
 * @Description: 菜单
 * @Version: 1.0
 */

@Service
public class MenuServiceImpl implements MenuService {

    @Override
    public List<MenuVo> getMenuList(Integer userId) {
        //可拓展根据用户角色返回有权限的菜单
        List<MenuVo> menuList = null;
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            InputStream inputStream = getClass().getClassLoader().getResourceAsStream("menu.json");
            menuList = objectMapper.readValue(inputStream, new TypeReference<List<MenuVo>>() {});
        } catch (IOException e) {
            e.printStackTrace();
        }
        return menuList;
    }
}
